<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>注册 - MAN商城</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
    <style>
        :root {
            --primary-color: #9c27b0; /* 紫色主题色 */
            --secondary-color: #4a148c; /* 深紫色 */
            --light-color: #f3e5f5; /* 淡紫色背景 */
            --text-color: #4a148c; /* 主要文字颜色 */
            --light-text: #7b1fa2; /* 浅色文字 */
            --border-color: #d1c4e9; /* 边框颜色 */
            --error-color: #d32f2f; /* 错误提示颜色 */
            --success-color: #388e3c; /* 成功提示颜色 */
        }
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
        }
        
        body {
            background-color: #f3e5f5;
            background-image: url('https://images.unsplash.com/photo-1518895949257-7621c3c786d7?ixlib=rb-1.2.1&auto=format&fit=crop&w=1920&q=80');
            background-size: cover;
            background-position: center;
            background-attachment: fixed;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            padding: 20px;
        }
        
        .register-container {
            background-color: rgba(255, 255, 255, 0.9);
            border-radius: 8px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
            width: 100%;
            max-width: 500px;
            padding: 40px;
            position: relative;
            overflow: hidden;
        }
        
        .register-container::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 4px;
            background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
        }
        
        h2 {
            text-align: center;
            color: var(--secondary-color);
            margin-bottom: 30px;
            font-size: 24px;
            font-weight: 600;
        }
        
        .form-group {
            margin-bottom: 20px;
            position: relative;
        }
        
        label {
            display: block;
            margin-bottom: 8px;
            color: var(--text-color);
            font-size: 14px;
            font-weight: 500;
        }
        
        input {
            width: 100%;
            padding: 12px 15px;
            border: 1px solid var(--border-color);
            border-radius: 4px;
            font-size: 14px;
            transition: all 0.3s;
            color: var(--text-color);
        }
        
        input::placeholder {
            color: #b39ddb;
        }
        
        input:focus {
            border-color: var(--primary-color);
            box-shadow: 0 0 0 2px rgba(156, 39, 176, 0.2);
            outline: none;
        }
        
        .input-icon {
            position: relative;
        }
        
        .input-icon i {
            position: absolute;
            top: 50%;
            left: 15px;
            transform: translateY(-50%);
            color: var(--light-text);
        }
        
        .input-icon input {
            padding-left: 40px;
        }
        
        .error-message {
            color: var(--error-color);
            font-size: 12px;
            margin-top: 5px;
            display: block;
            height: 16px;
        }
        
        .success-message {
            color: var(--success-color);
            font-size: 12px;
            margin-top: 5px;
            display: block;
            height: 16px;
        }
        
        .captcha-container {
            display: flex;
            gap: 10px;
        }
        
        .captcha-container input {
            flex: 1;
        }
        
        .captcha-image {
            width: 120px;
            height: 42px;
            background-color: #f0f0f0;
            border-radius: 4px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            user-select: none;
            font-family: 'Arial', sans-serif;
            font-size: 18px;
            letter-spacing: 2px;
            color: var(--text-color);
            position: relative;
            overflow: hidden;
        }
        
        .captcha-image::before {
            content: '';
            position: absolute;
            width: 100%;
            height: 100%;
            background: linear-gradient(45deg, transparent 45%, rgba(255,255,255,0.5) 45%, rgba(255,255,255,0.5) 55%, transparent 55%),
                        linear-gradient(-45deg, transparent 45%, rgba(255,255,255,0.5) 45%, rgba(255,255,255,0.5) 55%, transparent 55%);
            background-size: 10px 10px;
        }
        
        .agreement {
            display: flex;
            align-items: flex-start;
            margin: 20px 0;
        }
        
        .agreement input {
            width: auto;
            margin-right: 10px;
            margin-top: 3px;
        }
        
        .agreement label {
            margin-bottom: 0;
            color: var(--text-color);
            font-size: 13px;
            line-height: 1.5;
        }
        
        .agreement a {
            color: var(--primary-color);
            text-decoration: none;
        }
        
        .agreement a:hover {
            text-decoration: underline;
        }
        
        button[type="submit"] {
            width: 100%;
            padding: 14px;
            background-color: var(--primary-color);
            color: white;
            border: none;
            border-radius: 4px;
            font-size: 16px;
            font-weight: 500;
            cursor: pointer;
            transition: background-color 0.3s;
        }
        
        button[type="submit"]:hover {
            background-color: var(--secondary-color);
        }
        
        .form-footer {
            text-align: center;
            margin-top: 20px;
            color: var(--light-text);
            font-size: 14px;
        }
        
        .form-footer a {
            color: var(--primary-color);
            text-decoration: none;
            margin-left: 5px;
        }
        
        .form-footer a:hover {
            text-decoration: underline;
        }
        
        .social-login {
            margin-top: 30px;
            text-align: center;
        }
        
        .social-login p {
            position: relative;
            color: var(--light-text);
            font-size: 14px;
            margin-bottom: 20px;
        }
        
        .social-login p::before,
        .social-login p::after {
            content: '';
            position: absolute;
            top: 50%;
            width: 30%;
            height: 1px;
            background-color: var(--border-color);
        }
        
        .social-login p::before {
            left: 0;
        }
        
        .social-login p::after {
            right: 0;
        }
        
        .social-icons {
            display: flex;
            justify-content: center;
            gap: 15px;
        }
        
        .social-icon {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 18px;
            cursor: pointer;
            transition: transform 0.3s;
        }
        
        .social-icon:hover {
            transform: translateY(-3px);
        }
        
        .icon-wechat {
            background-color: #07C160;
        }
        
        .icon-qq {
            background-color: #12B7F5;
        }
        
        .icon-weibo {
            background-color: #E6162D;
        }
        
        .password-strength {
            margin-top: 5px;
            height: 4px;
            background-color: #e1bee7;
            border-radius: 2px;
            overflow: hidden;
        }
        
        .strength-bar {
            height: 100%;
            width: 0;
            transition: width 0.3s, background-color 0.3s;
        }
        
        .strength-weak {
            background-color: #f44336;
            width: 33%;
        }
        
        .strength-medium {
            background-color: #ff9800;
            width: 66%;
        }
        
        .strength-strong {
            background-color: #4caf50;
            width: 100%;
        }
        
        .password-tips {
            font-size: 12px;
            color: var(--light-text);
            margin-top: 5px;
        }
        
        @media (max-width: 576px) {
            .register-container {
                padding: 30px 20px;
            }
            
            .captcha-container {
                flex-direction: column;
            }
            
            .captcha-image {
                width: 100%;
                height: 40px;
            }
        }
    </style>
</head>
<body>
    <div class="register-container">
        <h2>欢迎注册MAN商城</h2>
        <form id="registerForm">
            <div class="form-group input-icon">
                <label for="username">用户名</label>
                <i class="fas fa-user"></i>
                <input type="text" id="username" name="username" placeholder="4-16位字母、数字或下划线" required>
                <span class="error-message" id="usernameError"></span>
            </div>
            
            <div class="form-group input-icon">
                <label for="password">密码</label>
                <i class="fas fa-lock"></i>
                <input type="password" id="password" name="password" placeholder="至少8位，包含字母和数字" required>
                <div class="password-strength">
                    <div class="strength-bar" id="passwordStrength"></div>
                </div>
                <div class="password-tips">建议使用字母、数字和符号的组合</div>
                <span class="error-message" id="passwordError"></span>
            </div>
            
            <div class="form-group input-icon">
                <label for="confirmPassword">确认密码</label>
                <i class="fas fa-lock"></i>
                <input type="password" id="confirmPassword" name="confirmPassword" placeholder="请再次输入密码" required>
                <span class="error-message" id="confirmPasswordError"></span>
            </div>
            
            <div class="form-group input-icon">
                <label for="phone">手机号码</label>
                <i class="fas fa-mobile-alt"></i>
                <input type="tel" id="phone" name="phone" placeholder="11位手机号码" required>
                <span class="error-message" id="phoneError"></span>
            </div>
            
            <div class="form-group">
                <label for="smsCode">短信验证码</label>
                <div class="captcha-container">
                    <input type="text" id="smsCode" name="smsCode" placeholder="6位验证码" required>
                    <button type="button" id="sendSmsBtn" style="width: 120px; background: #f3e5f5; border: 1px solid #d1c4e9; cursor: pointer; color: var(--text-color);">获取验证码</button>
                </div>
                <span class="error-message" id="smsCodeError"></span>
            </div>
            
            <div class="form-group input-icon">
                <label for="email">电子邮箱（可选）</label>
                <i class="fas fa-envelope"></i>
                <input type="email" id="email" name="email" placeholder="用于找回密码和接收优惠信息">
                <span class="error-message" id="emailError"></span>
            </div>
            
            <div class="agreement">
                <input type="checkbox" id="agree" name="agree" required>
                <label for="agree">我已阅读并同意<a href="#">《用户服务协议》</a>和<a href="#">《隐私政策》</a></label>
            </div>
            <span class="error-message" id="agreeError"></span>
            
            <button type="submit">立即注册</button>
            
            <div class="form-footer">
                已有账号？<a href="login.html">立即登录</a>
            </div>
            
            <div class="social-login">
                <p>其他登录方式</p>
                <div class="social-icons">
                    <div class="social-icon icon-wechat">
                        <i class="fab fa-weixin"></i>
                    </div>
                    <div class="social-icon icon-qq">
                        <i class="fab fa-qq"></i>
                    </div>
                    <div class="social-icon icon-weibo">
                        <i class="fab fa-weibo"></i>
                    </div>
                </div>
            </div>
        </form>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            const registerForm = document.getElementById('registerForm');
            const passwordInput = document.getElementById('password');
            const passwordStrength = document.getElementById('passwordStrength');
            const sendSmsBtn = document.getElementById('sendSmsBtn');
            
            // 密码强度检测
            passwordInput.addEventListener('input', function() {
                const password = this.value;
                let strength = 0;
                
                // 长度检查
                if (password.length >= 8) strength++;
                if (password.length >= 12) strength++;
                
                // 包含数字
                if (/\d/.test(password)) strength++;
                
                // 包含小写字母
                if (/[a-z]/.test(password)) strength++;
                
                // 包含大写字母
                if (/[A-Z]/.test(password)) strength++;
                
                // 包含特殊字符
                if (/[^a-zA-Z0-9]/.test(password)) strength++;
                
                // 更新强度条
                passwordStrength.className = 'strength-bar';
                if (password.length === 0) {
                    passwordStrength.style.width = '0';
                } else if (strength <= 2) {
                    passwordStrength.classList.add('strength-weak');
                } else if (strength <= 4) {
                    passwordStrength.classList.add('strength-medium');
                } else {
                    passwordStrength.classList.add('strength-strong');
                }
            });
            
            // 发送短信验证码
            sendSmsBtn.addEventListener('click', function() {
                const phone = document.getElementById('phone').value;
                const phoneError = document.getElementById('phoneError');
                
                // 简单手机号验证
                if (!/^1[3-9]\d{9}$/.test(phone)) {
                    phoneError.textContent = '请输入有效的手机号码';
                    return;
                }
                
                phoneError.textContent = '';
                
                // 倒计时效果
                let countdown = 60;
                sendSmsBtn.disabled = true;
                sendSmsBtn.textContent = `${countdown}秒后重新发送`;
                
                const timer = setInterval(() => {
                    countdown--;
                    sendSmsBtn.textContent = `${countdown}秒后重新发送`;
                    
                    if (countdown <= 0) {
                        clearInterval(timer);
                        sendSmsBtn.disabled = false;
                        sendSmsBtn.textContent = '获取验证码';
                    }
                }, 1000);
                
                // 这里应该发送AJAX请求获取验证码
                console.log('发送验证码到手机:', phone);
            });
            
            // 表单验证
            registerForm.addEventListener('submit', function(e) {
                e.preventDefault();
                let isValid = true;
                
                // 用户名验证
                const username = document.getElementById('username').value;
                const usernameError = document.getElementById('usernameError');
                if (!/^[a-zA-Z0-9_]{4,16}$/.test(username)) {
                    usernameError.textContent = '用户名应为4-16位字母、数字或下划线';
                    isValid = false;
                } else {
                    usernameError.textContent = '';
                }
                
                // 密码验证
                const password = document.getElementById('password').value;
                const passwordError = document.getElementById('passwordError');
                if (password.length < 8) {
                    passwordError.textContent = '密码长度不能少于8位';
                    isValid = false;
                } else if (!/\d/.test(password) || !/[a-zA-Z]/.test(password)) {
                    passwordError.textContent = '密码必须包含字母和数字';
                    isValid = false;
                } else {
                    passwordError.textContent = '';
                }
                
                // 确认密码验证
                const confirmPassword = document.getElementById('confirmPassword').value;
                const confirmPasswordError = document.getElementById('confirmPasswordError');
                if (password !== confirmPassword) {
                    confirmPasswordError.textContent = '两次输入的密码不一致';
                    isValid = false;
                } else {
                    confirmPasswordError.textContent = '';
                }
                
                // 手机号验证
                const phone = document.getElementById('phone').value;
                const phoneError = document.getElementById('phoneError');
                if (!/^1[3-9]\d{9}$/.test(phone)) {
                    phoneError.textContent = '请输入有效的手机号码';
                    isValid = false;
                } else {
                    phoneError.textContent = '';
                }
                
                // 短信验证码验证
                const smsCode = document.getElementById('smsCode').value;
                const smsCodeError = document.getElementById('smsCodeError');
                if (!/^\d{6}$/.test(smsCode)) {
                    smsCodeError.textContent = '请输入6位数字验证码';
                    isValid = false;
                } else {
                    smsCodeError.textContent = '';
                }
                
                // 邮箱验证（可选）
                const email = document.getElementById('email').value;
                const emailError = document.getElementById('emailError');
                if (email && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
                    emailError.textContent = '请输入有效的邮箱地址';
                    isValid = false;
                } else {
                    emailError.textContent = '';
                }
                
                // 协议勾选验证
                const agree = document.getElementById('agree').checked;
                const agreeError = document.getElementById('agreeError');
                if (!agree) {
                    agreeError.textContent = '请阅读并同意用户协议';
                    isValid = false;
                } else {
                    agreeError.textContent = '';
                }
                
                if (isValid) {
                    // 表单验证通过，可以提交
                    alert('注册成功！');
                    // 这里应该发送AJAX请求提交表单
                    console.log('提交注册表单:', {
                        username,
                        password,
                        phone,
                        smsCode,
                        email
                    });
                }
            });
        });
    </script>
</body>
</html>